package com.icode.core.dto.order;

import java.util.regex.Pattern;

/**
 * Created with IntelliJ IDEA.
 * User: xianfei
 * Date: 15-4-10
 * Time: 上午9:38
 * To change this template use File | Settings | File Templates.
 */
public class PageDTO {

    public static int pageOfData = 8;
    private String currentPage;
    private String totalPage;

    public PageDTO() {
    }

    public PageDTO(String currentPage, String totalPage) {
        this.currentPage = currentPage;
        this.totalPage = totalPage;
    }

    public static void setPageOfData(int pageOfData) {
        PageDTO.pageOfData = pageOfData;
    }

    public void setCurrentPage(String currentPage) {
        this.currentPage = currentPage;
    }

    public void setTotalPage(String totalPage) {
        this.totalPage = totalPage;
    }

    public static int getPageOfData() {
        return pageOfData;
    }

    public String getCurrentPage() {
        return currentPage;
    }

    public String getTotalPage() {
        return totalPage;
    }

    public static String isPage(String page, String maxPage) {
        boolean f = Pattern.matches("[1-9][0-9]*", page);
        if (f == false) {
            return "1";
        }
        if (Integer.valueOf(page) >= Integer.valueOf(maxPage)) {
            return maxPage;
        }
        return page;
    }

}
